<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo ($title); ?></title>
    <meta name="keywords" content="<?php echo ($title); ?>">
    <meta name="description" content="<?php echo ($title); ?>">
    <link href="/Public/static/admin/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="/Public/static/admin/css/style.min.css" rel="stylesheet">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>添加权限</h5>
                    <div class="ibox-tools">
                    </div>
                </div>
                <div class="ibox-content">
                    <form method="post" id="form1" name="form1" class="form-horizontal" action="">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">所属父级：</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="pid" id="pid">
                                    <option value="0">————顶级权限————</option>
                                    <?php if(is_array($rule_info)): $i = 0; $__LIST__ = $rule_info;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><option value="<?php echo ($v["id"]); ?>">
                                            <?php
 if($v['level']==1){ echo $v['title']; }else{ echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; for($i = 1; $i < $v['level']; $i++){ echo '-----'; } echo $v['title']; } ?>
                                        </option><?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">权限唯一标示：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="rule_name" name="rule_name">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">权限中文名称：</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="title" name="title">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-2">
                                <button class="btn btn-primary" type="submit">添 加</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/Public/static/admin/js/jquery.min.js"></script>
<script src="/Public/static/admin/js/jquery.form.js"></script>
<script src="/Public/static/admin/js/plugins/switchery/switchery.js"></script>
<script src="/Public/static/admin/js/plugins/layer/layer.min.js"></script>
<script src="/Public/static/admin/js/common.js"></script>
<script>
    $(function(){
        $('#form1').ajaxForm({
            beforeSubmit: checkFun,
            success: complete,
            dataType: 'json'
        });
        function checkFun(){
            if($('#pid').val() == ''){
                sxshop.error('父级不能为空！');
                return false;
            }
            if($('#rule_name').val() == ''){
                sxshop.error('权限唯一标示不能为空！');
                return false;
            }
            if($('#title').val() == ''){
                sxshop.error('权限中文名称不能为空！');
                return false;
            }
        }
        function complete(data){
            if(data.state > 0){
                sxshop.error(data.msg);
                return false;
            }else{
                sxshop.success(data.msg,'<?php echo U("index");?>')
            }
        }
    })
</script>
</body>
</html>